Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small SAST fixes #8534

Merged
merged 4 commits into from
Nov 25, 2024
Merged

Small SAST fixes #8534

merged 4 commits into from
Nov 25, 2024

Conversation

matmair
Copy link
Member

@matmair matmair commented Nov 20, 2024

No description provided.

@matmair matmair self-assigned this Nov 20, 2024
Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit b1d3d9b
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/6744f19c401962000870f2e8
😎 Deploy Preview https://deploy-preview-8534--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 86 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.51%. Comparing base (0f194af) to head (b1d3d9b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...c/frontend/src/tables/part/ParametricPartTable.tsx 0.00% 3 Missing ⚠️
...rontend/src/components/importer/ImporterDrawer.tsx 0.00% 1 Missing ⚠️
src/frontend/src/tables/settings/TemplateTable.tsx 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8534      +/-   ##
==========================================
- Coverage   84.52%   84.51%   -0.01%     
==========================================
  Files        1178     1178              
  Lines       53709    53582     -127     
  Branches     2028     2027       -1     
==========================================
- Hits        45396    45285     -111     
+ Misses       7806     7790      -16     
  Partials      507      507              
Flag Coverage Δ
pui 68.67% <44.44%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -81,6 +80,7 @@ export default function ImporterDrawer({
return 3;
case importSessionStatus.COMPLETE:
return 4;
default:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'default' case should return a value here still, otherwise you are changing functionality.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? default is empty in the current code base

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scratch that

@@ -84,7 +84,7 @@ export const getPluginTemplateEditor = (
useEffect(() => {
(async () => {
try {
await func({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the await needed here so that asynchronous errors are catched too? But not sure about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't func be marked async for that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be asynchronous if

https://github.com/inventree/InvenTree/blob/master/src/frontend/src/components/plugins/PluginUIFeatureTypes.ts#L1is defined as a promise by the individual feature.

Copy link
Contributor

@wolflu05 wolflu05 Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you’re right, in this case it can’t be async, so its fine removing it. Good catch.

Or we could define it as void | Promise<void> instead of undefined in the Template editor feature, and use await Promise.resolve(func)… then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH all of those were caught by SonarCloud and were marked as middle to high importance so I mainly fixed them to get the quality gate back to good-ish before the release

@SchrodingersGat SchrodingersGat added this to the 0.17.0 milestone Nov 25, 2024
@SchrodingersGat SchrodingersGat merged commit 5cda270 into inventree:master Nov 25, 2024
22 checks passed
@SchrodingersGat SchrodingersGat deleted the sast-fixes branch November 25, 2024 22:15
@SchrodingersGat
Copy link
Member

Thanks @matmair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants